﻿using System;

namespace Just4Devs.Vsirc.Addin.UI
{
	class VsircTabFactory
	{
		protected TabType GetTabType(string name)
		{
			if (name.StartsWith("#"))
				return TabType.Channel;
			else
				return TabType.Private;
		}

		/// <summary>
		/// Creates a tab to a director.
		/// </summary>
		/// <param name="name">The name of the tab.</param>
		/// <param name="director">The director.</param>
		/// <returns>
		/// A new channel or private tab instance (according to its name).
		/// </returns>
		public IVsircTab CreateTab(string name, VsircScreenDirector director)
		{
			IVsircTab returningTab = null;
			switch (GetTabType(name))
			{
				case TabType.Private:
					returningTab = new VsircPrivateConversation(name, director);
					break;
				case TabType.Channel:
					returningTab = new VsircChannelTab(name, director);
					break;
				default:
					throw new NotSupportedException();
			}
			return returningTab;
		}
	}

	public enum TabType
	{
		Private,
		Channel
	}
}
